﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SO
{
    class StatisticsDisplay : Observer, DisplayElement
    {
        private float temperature;
        private float humidity;

        // 保留一个联系方式，电话.
        // 可以更换收听者
        private Subject weatherData;


        public StatisticsDisplay(Subject s)
        {
            this.weatherData = s;

            weatherData.registerObserver(this);
        }

        public void update(float temperature, float humidity, float pressure)
        {
            this.temperature = temperature;
            this.humidity = humidity;

            display();
        }

        public void display()
        {
            Console.WriteLine("Avg/Max/Min temperature = {0} / {1}", 
                                temperature, humidity);
        }
    }
}
